<template>
  <div class="toggle_controls">
    <button class="toggle_btn" @click="toggle_layer('vector')">
      <img
        src="/src/assets/imgs/vector.png"
        alt="矢量图层"
        class="toggle_img"
        title="矢量图层"
      />
    </button>
    <button class="toggle_btn" @click="toggle_layer('image')">
      <img
        src="/src/assets/imgs/image.png"
        alt="影像图层"
        class="toggle_img"
        title="影像图层"
      />
    </button>
  </div>
</template>

<script>
import { gaode_vector, gaode_image } from "../libs/mapBase";
import Vue from 'vue'
let $map = null;
export default {
  methods: {
    toggle_layer(index) {
      if (index === "vector") {
        gaode_vector.setVisible(true);
        gaode_image.setVisible(false);
      } else {
        gaode_vector.setVisible(false);
        gaode_image.setVisible(true);
      }
    },
  },
  mounted() {
    // $map = Vue.prototype.$map;
    $map = this.$map;
    console.log(this,'this')
    console.log($map,'$map');
  },
};
</script>

<style lang="scss" scoped>
.toggle_controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
}
.toggle_btn {
  width: 50px;
  height: 50px;
  cursor: pointer;
  // border: none;
  border: 1px solid #eee;
  border-radius: 50%;
  overflow: hidden;
  .toggle_img {
    vertical-align: bottom;
    width: 100%;
    height: 100%;
  }
  &:not(&:first-child) {
    margin-left: 10px;
  }
}
</style>
